<?php
use yii\helpers\Html;
use common\modules\system\models\DataDictionary;
use common\helpers\Constants;
use common\helpers\TreeHelper;
use yii\bootstrap\ActiveForm;

/* @var $this yii\web\View */
/* @var $model common\modules\system\models\DataDictionary */
/* @var $form yii\widgets\ActiveForm */

$category = $model->category_id;
$categories = DataDictionary::getArrayTree($category);
$options = TreeHelper::buildTreeOptionsForSelf($categories, $model);
?>

<?= Html::a('返回', ['index','category'=>$category], ['class' => 'btn btn-primary'])?>
<div class="data-dictionary-form">
    <?php $form = ActiveForm::begin(); ?>

    <div class="da-form-row">
		<label>父结点</label>
		<div class="da-form-item small">
            <?php echo Html::activeHiddenInput($model, 'category_id')?>
            <select type="text" id="menu-parent_id" class="form-control"
				name="DataDictionary[parent_id]">
            <?php echo $options?>
            </select>
		</div>
	</div>

    <?= $form->field($model, 'name')->textInput(['maxlength' => 64]) ?>

    <?= $form->field($model, 'value')->textarea() ?>

    <?= $form->field($model, 'thumbnail')->textInput(['maxlength' => 512]) ?>
    <?= $form->field($model, 'description')->textarea(['maxlength' => 512]) ?>    

    <?= $form->field($model, 'sort')->textInput() ?>
    <?= $form->field($model, 'status')->radioList(Constants::getStatusItems()) ?>

    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? Yii::t('backend', 'Create') : Yii::t('backend', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary'])?>
    </div>

    <?php ActiveForm::end(); ?>

</div>
